


clear all
cd "/Users/michaelflynn/Dropbox/EmigrationSafetyValve/JPR Submission/JPR Data & Do Files"
use "/Users/michaelflynn/Dropbox/EmigrationSafetyValve/JPR Submission/JPR Data & Do Files/ESV-MasterData(1980-2009).dta"
set more off
set seed 5590

estsimp nbreg totalprotest unemploy_g7 formov g7formov kof_eg  kofegXg7unemp dommov physint polityb ln_develop growth ln_population adultpop war colonydum  peaceyr_tp if G7==0 & democracy==0 & rights<2, robust sims(20000)

setx mean
setx war 0 colonydum 0 

setx formov 0 g7formov 0 unemploy_g7 6 kof_eg 40 kofegXg7unemp 240
simqi, ev genev(predicted_count0)

setx formov 1 g7formov 6
simqi, ev genev(predicted_count1)

setx formov 2 g7formov 12
simqi, ev genev(predicted_count2)

setx unemploy_g7 8.8

setx formov 0 g7formov 0 kofegXg7unemp 352
simqi, ev genev(predicted_count3)

setx formov 1 g7formov 8.8
simqi, ev genev(predicted_count4)

setx formov 2 g7formov 17.6
simqi, ev genev(predicted_count5)


foreach var of varlist predicted_count0-predicted_count5 {
_pctile `var', p(2.5,97.5)
replace `var' = . if `var' < r(r1) | `var' > r(r2)
}

twoway hist predicted_count0, color(black) bin(40)  || hist predicted_count2, bin(40) color(gs10)  xlabel(0(1)4.0) ///
subtitle(`"(a)"' `"G7 unemployment at 6%"') legend(off) xtitle(Predicted protest count) 
graph save unemploy_low.gph, replace

twoway hist predicted_count3, color(black) bin(40)  || hist predicted_count5, color(gs10) bin(40)  xlabel(0(1)4.0) ///
subtitle(`"(b)"' `"G7 unemployment at 8.8%"') legend(lab(1 Foreign movement = 0) lab(2 Foreign movement = 2) ///
cols(1) symxsize(3)) xtitle(Predicted protest count) ylabel(0(1)4)
graph save unemploy_high.gph, replace

grc1leg unemploy_low.gph unemploy_high.gph, cols(1) legendfrom(unemploy_high.gph) pos(3) ring(1)  

graph export "Protest Simulation.pdf", replace
